/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SPasswordInfoConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.todo.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.todo.ATaskWithOperation;
import com.thor.palmmall.spi.todo.STaskWithOperation;

/**
 * @author wolv
 *
 */
public class ATaskWithOperationConverter
    implements Converter<STaskWithOperation, ATaskWithOperation> {

  public static ATaskWithOperationConverter getInstance() {
    if (instance == null)
      instance = new ATaskWithOperationConverter();
    return instance;
  }

  private static ATaskWithOperationConverter instance;

  private ATaskWithOperationConverter() {
  }

  @Override
  public ATaskWithOperation convert(STaskWithOperation source) {
    if (source == null)
      return null;

    ATaskWithOperation target = new ATaskWithOperation();
    target.setBillType(source.getBillType());
    target.setBillUuid(source.getBillUuid());
    target.setStore(UCN.newInstance(source.getStore()));
    target.setTime(source.getTime());
    target.setTitle(source.getTitle());
    target.setUuid(source.getUuid());
    target.setOperates(
        ConverterUtil.convert(source.getOperates(), ATaskOperationConverter.getInstance()));
    target.setEndTime(source.getEndTime());
    target.setAssignee(source.getAssignee());
    target.setAssigneeName(source.getAssigneeName());
    return target;
  }

}
